﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="pragma" content="no-cache" />
    <meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
    <meta http-equiv="expires" content="0" />
    <title>FaceCat-Html5</title>
</head>
<body>
    <canvas id="treeCanvas" width="1000" height="700" style="position: fixed; left: 0px; top: 0px;"/>
    <script type="text/javascript" src="facecat.js"></script>
    <script type="text/javascript">
        let canvasTree = document.getElementById("treeCanvas"); //绘图区域
        canvasTree.width = window.innerWidth;
        canvasTree.height = window.innerHeight;
        let paintTree = new FCPaint(); //绘图对象
        paintTree.canvas = canvasTree;
        scaleCanvas(paintTree);
        //判断移动端
        paintTree.isMobile = isMobileMode();
        if (paintTree.isMobile) {
            paintTree.scaleFactorX = 2.5;
            paintTree.scaleFactorY = 2.5;
        }
        //判断主题色
        paintTree.defaultUIStyle = "dark";
        let url = location.href;
        if (url.indexOf("color=light") != -1) {
            paintTree.defaultUIStyle = "light";
        }
        addDefaultEvent(canvasTree, paintTree);

        //创建树
        let tree = new FCTree();

        /*
        * 创建列
        * tree:树
        */
        let createTreeColumn = function (tree) {
            let treeColumn = new FCTreeColumn();
            if (tree.paint.defaultUIStyle == "dark") {
                treeColumn.backColor = "rgb(0,0,0)";
                treeColumn.borderColor = "rgb(100,100,100)";
                treeColumn.textColor = "rgb(255,255,255)";
            } else if (tree.paint.defaultUIStyle == "light") {
                treeColumn.backColor = "rgb(200,200,200)";
                treeColumn.borderColor = "rgb(150,150,150)";
                treeColumn.textColor = "rgb(0,0,0)";
            }
            return treeColumn;
        };

        /*
        * 创建列
        * tree:树
        */
        let createTreeNode = function (tree) {
            let treeNode = new FCTreeNode();
            if (tree.paint.defaultUIStyle == "dark") {
                treeNode.backColor = "rgb(0,0,0)";
                treeNode.borderColor = "rgb(100,100,100)";
                treeNode.textColor = "rgb(255,255,255)";
            } else if (tree.paint.defaultUIStyle == "light") {
                treeNode.backColor = "rgb(255,255,255)";
                treeNode.borderColor = "rgb(150,150,150)";
                treeNode.textColor = "rgb(0,0,0)";
            }
            return treeNode;
        };

        /*
        * 初始化树
        */
        let initTree = function () {
            tree.dock = "fill";
            addView(tree, paintTree);
            tree.paint = paintTree;
            if (tree.paint.defaultUIStyle == "dark") {
                tree.backColor = "rgb(0,0,0)";
                tree.borderColor = "rgb(100,100,100)";
                tree.textColor = "rgb(255,255,255)";
                tree.scrollBarColor = "rgb(100,100,100)";
            } else if (tree.paint.defaultUIStyle == "light") {
                tree.backColor = "rgb(255,255,255)";
                tree.borderColor = "rgb(150,150,150)";
                tree.textColor = "rgb(0,0,0)";
                tree.scrollBarColor = "rgb(200,200,200)";
            }
            tree.showCheckBox = true;

            let column = createTreeColumn(tree);
            column.widthStr = "100%";
            tree.columns.push(column);

            let rootNode = createTreeNode(tree);
            rootNode.value = "证监会行业类";
            appendTreeNode(tree, rootNode, null);

            let node1 = createTreeNode(tree);
            node1.value = "农、林、牧、渔业";
            appendTreeNode(tree, node1, rootNode);

            let strs1 = new Array();
            strs1.push("农业");
            strs1.push("林业");
            strs1.push("畜牧业");
            strs1.push("渔业");
            strs1.push("农、林、牧、渔服务业");
            for (let i = 0; i < strs1.length; i++) {
                let subNode1 = createTreeNode(tree);
                subNode1.value = strs1[i];
                appendTreeNode(tree, subNode1, node1);
            }

            let node2 = createTreeNode(tree);
            node2.value = "采矿业";
            appendTreeNode(tree, node2, rootNode);

            let strs2 = new Array();
            strs2.push("煤炭开采和洗选业");
            strs2.push("石油和天然气开采业");
            strs2.push("黑色金属矿采选业");
            strs2.push("有色金属矿采选业");
            strs2.push("非金属矿采选业");
            strs2.push("开采辅助活动");
            for (let i = 0; i < strs2.length; i++) {
                let subNode2 = createTreeNode(tree);
                subNode2.value = strs2[i];
                appendTreeNode(tree, subNode2, node2);
            }

            let node3 = createTreeNode(tree);
            node3.value = "制造业";
            appendTreeNode(tree, node3, rootNode);

            let strs3 = new Array();
            strs3.push("农副食品加工业");
            strs3.push("食品制造业");
            strs3.push("酒、饮料和精制茶制造业");
            strs3.push("纺织业");
            strs3.push("纺织服装、服饰业");
            strs3.push("皮革、毛皮、羽毛及其制品和制鞋业");
            strs3.push("木材加工和木、竹、藤、棕、草制品业");
            strs3.push("家具制造业");
            strs3.push("造纸和纸制品业");
            strs3.push("印刷和记录媒介复制业");
            strs3.push("文教、工美、体育和娱乐用品制造业");
            strs3.push("石油加工、炼焦和核燃料加工业");
            strs3.push("化学原料及化学制品制造业");
            strs3.push("医药制造业");
            strs3.push("化学纤维制造业");
            strs3.push("橡胶和塑料制品业");
            strs3.push("非金属矿物制品业");
            strs3.push("黑色金属冶炼和压延加工业");
            strs3.push("有色金属冶炼和压延加工业");
            strs3.push("金属制品业");
            strs3.push("通用设备制造业");
            strs3.push("专用设备制造业");
            strs3.push("汽车制造业");
            strs3.push("铁路、船舶、航空航天和其他运输设备制造业");
            strs3.push("电气机械和器材制造业");
            strs3.push("计算机、通信和其他电子设备制造业");
            strs3.push("仪器仪表制造业");
            strs3.push("其他制造业");
            strs3.push("废弃资源综合利用业");
            for (let i = 0; i < strs3.length; i++) {
                let subNode3 = createTreeNode(tree);
                subNode3.value = strs3[i];
                appendTreeNode(tree, subNode3, node3);
            }
        };

        initTree();

        /*
        * 表格的点击方法
        * tree: 树
        * firstTouch:是否第一次触摸
        * firstPoint:第一次触摸的坐标
        * secondTouch:是否第二次触摸
        * secondPoint:第二次触摸的坐标
        * clicks:点击次数
        */
        paintTree.onClickTreeNode = function (tree, node, firstTouch, firstPoint, secondTouch, secondPoint, clicks) {
        };

        /*
        * 重置大小
        */
        let resizeAll = function () {
            canvasTree.width = document.documentElement.clientWidth;
            canvasTree.height = document.documentElement.clientHeight;
            scaleCanvas(paintTree);
            updateViewDefault(paintTree.views);
            invalidate(paintTree);
        };

        /*
        * 监听大小改变
        */
        window.onresize = function () {
            resizeAll();
        };

        /*
        * 旋转监听
        */
        window.onorientationchange = function () {
            resizeAll();
        };
        updateViewDefault(paintTree.views);
        //刷新界面
        invalidate(paintTree);
    </script>
</body>
</html>
